sanity-plugin-media 2.3.0 → 2.3.2
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 +23 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.esm.js +142 -102
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +141 -101
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DialogAssetEdit/index.tsx +19 -0
- package/src/components/SearchFacetsControl/index.tsx +8 -0
- package/src/components/Tool/index.tsx +5 -10
- package/src/config/searchFacets.ts +10 -0
- package/src/constants.ts +1 -0
- package/src/contexts/ToolOptionsContext.tsx +23 -7
- package/src/formSchema/index.ts +1 -0
- package/src/index.ts +2 -47
- package/src/modules/assets/index.ts +4 -0
- package/src/plugin.tsx +53 -0
- package/src/types/index.ts +6 -0
- package/src/utils/constructFilter.ts +1 -1
package/README.md
CHANGED
|
@@ -95,6 +95,29 @@ export default defineConfig({
|
|
|
95
95
|
})
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
### Plugin Config
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
// sanity.config.ts
|
|
102
|
+
export default defineConfig({
|
|
103
|
+
//...
|
|
104
|
+
plugins: [
|
|
105
|
+
media({
|
|
106
|
+
creditLine: {
|
|
107
|
+
enabled: true,
|
|
108
|
+
// boolean - enables an optional "Credit Line" field in the plugin.
|
|
109
|
+
// Used to store credits e.g. photographer, licence information
|
|
110
|
+
excludeSources: ['unsplash'],
|
|
111
|
+
// string | string[] - when used with 3rd party asset sources, you may
|
|
112
|
+
// wish to prevent users overwriting the creditLine based on the `source.name`
|
|
113
|
+
},
|
|
114
|
+
maximumUploadSize: 10000000
|
|
115
|
+
// number - maximum file size (in bytes) that can be uploaded through the plugin interface
|
|
116
|
+
})
|
|
117
|
+
],
|
|
118
|
+
})
|
|
119
|
+
```
|
|
120
|
+
|
|
98
121
|
## Known issues
|
|
99
122
|
|
|
100
123
|
<details>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {AssetSourceComponentProps} from 'sanity'
|
|
2
|
+
import {JSX as JSX_2} from 'react/jsx-runtime'
|
|
2
3
|
import {Plugin as Plugin_2} from 'sanity'
|
|
4
|
+
import {default as React_2} from 'react'
|
|
3
5
|
|
|
4
6
|
export declare const media: Plugin_2<void | MediaToolOptions>
|
|
5
7
|
|
|
6
|
-
export declare const mediaAssetSource:
|
|
8
|
+
export declare const mediaAssetSource: {
|
|
9
|
+
component: (props: AssetSourceComponentProps) => JSX_2.Element
|
|
10
|
+
icon: React_2.ForwardRefExoticComponent<
|
|
11
|
+
Omit<React_2.SVGProps<SVGSVGElement>, 'ref'> & React_2.RefAttributes<SVGSVGElement>
|
|
12
|
+
>
|
|
13
|
+
name: string
|
|
14
|
+
title: string
|
|
15
|
+
}
|
|
7
16
|
|
|
8
|
-
declare type MediaToolOptions = {
|
|
17
|
+
export declare type MediaToolOptions = {
|
|
9
18
|
maximumUploadSize?: number
|
|
19
|
+
creditLine: {
|
|
20
|
+
enabled: boolean
|
|
21
|
+
excludeSources?: string | string[]
|
|
22
|
+
}
|
|
10
23
|
}
|
|
11
24
|
|
|
12
25
|
export {}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useClient, useColorScheme, useSchema, Preview, useDocumentStore, WithReferringDocuments, useFormValue, definePlugin } from 'sanity';
|
|
2
|
-
import { forwardRef, createElement, useRef, useCallback, useEffect, createContext, useContext, useState, memo, Component, useMemo } from 'react';
|
|
3
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useClient, useColorScheme, useSchema, Preview, useDocumentStore, WithReferringDocuments, useFormValue, definePlugin } from 'sanity';
|
|
3
|
+
import { forwardRef, createElement, useRef, useCallback, useEffect, createContext, useContext, useMemo, useState, memo, Component } from 'react';
|
|
4
4
|
import { Inline, Button, usePortal, MenuButton, Menu as Menu$2, MenuItem, MenuDivider, Box, studioTheme, rem, Flex, Label, Text, TextInput, Card, MenuGroup, useMediaIndex, Tooltip, Switch, Popover, Stack, Dialog as Dialog$1, TextArea, TabList, Tab, TabPanel, Container as Container$2, Spinner, Checkbox, Grid, useToast, ThemeProvider, ToastProvider, PortalProvider, useLayer, Portal } from '@sanity/ui';
|
|
5
5
|
import isHotkey from 'is-hotkey';
|
|
6
6
|
import groq from 'groq';
|
|
@@ -4146,6 +4146,16 @@ const inputs = {
|
|
|
4146
4146
|
type: "string",
|
|
4147
4147
|
value: ""
|
|
4148
4148
|
},
|
|
4149
|
+
creditLine: {
|
|
4150
|
+
assetTypes: ["file", "image"],
|
|
4151
|
+
field: "creditLine",
|
|
4152
|
+
name: "creditLine",
|
|
4153
|
+
operatorType: "empty",
|
|
4154
|
+
operatorTypes: ["empty", "notEmpty", null, "includes", "doesNotInclude"],
|
|
4155
|
+
title: "Credit",
|
|
4156
|
+
type: "string",
|
|
4157
|
+
value: ""
|
|
4158
|
+
},
|
|
4149
4159
|
description: {
|
|
4150
4160
|
assetTypes: ["file", "image"],
|
|
4151
4161
|
field: "description",
|
|
@@ -4414,7 +4424,7 @@ null, {
|
|
|
4414
4424
|
direction: "asc",
|
|
4415
4425
|
field: "size"
|
|
4416
4426
|
}];
|
|
4417
|
-
const FACETS = [inputs.tag, divider, inputs.inUse, inputs.inCurrentDocument, divider, inputs.title, inputs.altText, inputs.description, divider, inputs.isOpaque, divider, inputs.fileName, inputs.size, inputs.type, divider, inputs.orientation, inputs.width, inputs.height];
|
|
4427
|
+
const FACETS = [inputs.tag, divider, inputs.inUse, inputs.inCurrentDocument, divider, inputs.title, inputs.altText, inputs.creditLine, inputs.description, divider, inputs.isOpaque, divider, inputs.fileName, inputs.size, inputs.type, divider, inputs.orientation, inputs.width, inputs.height];
|
|
4418
4428
|
const GRID_TEMPLATE_COLUMNS = {
|
|
4419
4429
|
SMALL: "3rem 100px auto 1.5rem",
|
|
4420
4430
|
LARGE: "3rem 100px auto 5.5rem 5.5rem 3.5rem 8.5rem 4.75rem 2rem"
|
|
@@ -4563,7 +4573,7 @@ const constructFilter = _ref => {
|
|
|
4563
4573
|
// NOTE: Currently this only searches direct fields on sanity.fileAsset/sanity.imageAsset and NOT referenced tags
|
|
4564
4574
|
// It's possible to add this by adding the following line to the searchQuery, but it's quite slow
|
|
4565
4575
|
// references(*[_type == "media.tag" && name.current == "${searchQuery.trim()}"]._id)
|
|
4566
|
-
...(searchQuery ? [groq(_b$a || (_b$a = __template$j(["[_id, altText, assetId, description, originalFilename, title, url] match '*", "*'"])), searchQuery.trim())] : []),
|
|
4576
|
+
...(searchQuery ? [groq(_b$a || (_b$a = __template$j(["[_id, altText, assetId, creditLine, description, originalFilename, title, url] match '*", "*'"])), searchQuery.trim())] : []),
|
|
4567
4577
|
// Search facets
|
|
4568
4578
|
...searchFacetFragments].join(" && ");
|
|
4569
4579
|
return constructedQuery;
|
|
@@ -5385,7 +5395,7 @@ const assetsSlice = createSlice({
|
|
|
5385
5395
|
sort = groq(_a$g || (_a$g = __template$g(["order(_updatedAt desc)"])))
|
|
5386
5396
|
} = _ref19;
|
|
5387
5397
|
const pipe = sort || selector ? "|" : "";
|
|
5388
|
-
const query = groq(_b$8 || (_b$8 = __template$g(['\n {\n "items": *[', "] {\n _id,\n _type,\n _createdAt,\n _updatedAt,\n altText,\n description,\n extension,\n metadata {\n dimensions,\n exif,\n isOpaque,\n },\n mimeType,\n opt {\n media\n },\n originalFilename,\n size,\n title,\n url\n } ", " ", " ", ",\n }\n "])), queryFilter, pipe, sort, selector);
|
|
5398
|
+
const query = groq(_b$8 || (_b$8 = __template$g(['\n {\n "items": *[', "] {\n _id,\n _type,\n _createdAt,\n _updatedAt,\n altText,\n creditLine,\n description,\n extension,\n metadata {\n dimensions,\n exif,\n isOpaque,\n },\n mimeType,\n opt {\n media\n },\n originalFilename,\n size,\n source {\n name\n },\n title,\n url\n } ", " ", " ", ",\n }\n "])), queryFilter, pipe, sort, selector);
|
|
5389
5399
|
return {
|
|
5390
5400
|
payload: {
|
|
5391
5401
|
params,
|
|
@@ -7227,14 +7237,55 @@ const SearchFacets = props => {
|
|
|
7227
7237
|
}
|
|
7228
7238
|
throw Error("Invalid layout");
|
|
7229
7239
|
};
|
|
7240
|
+
const ToolOptionsContext = createContext(null);
|
|
7241
|
+
const ToolOptionsProvider = _ref43 => {
|
|
7242
|
+
let {
|
|
7243
|
+
options,
|
|
7244
|
+
children
|
|
7245
|
+
} = _ref43;
|
|
7246
|
+
var _a, _b;
|
|
7247
|
+
const value = useMemo(() => {
|
|
7248
|
+
var _a2, _b2, _c, _d;
|
|
7249
|
+
let creditLineExcludeSources;
|
|
7250
|
+
if ((_a2 = options == null ? void 0 : options.creditLine) == null ? void 0 : _a2.excludeSources) {
|
|
7251
|
+
creditLineExcludeSources = Array.isArray((_b2 = options == null ? void 0 : options.creditLine) == null ? void 0 : _b2.excludeSources) ? options.creditLine.excludeSources : [(_c = options == null ? void 0 : options.creditLine) == null ? void 0 : _c.excludeSources];
|
|
7252
|
+
}
|
|
7253
|
+
return {
|
|
7254
|
+
dropzone: {
|
|
7255
|
+
maxSize: options == null ? void 0 : options.maximumUploadSize
|
|
7256
|
+
},
|
|
7257
|
+
creditLine: {
|
|
7258
|
+
enabled: ((_d = options == null ? void 0 : options.creditLine) == null ? void 0 : _d.enabled) || false,
|
|
7259
|
+
excludeSources: creditLineExcludeSources
|
|
7260
|
+
}
|
|
7261
|
+
};
|
|
7262
|
+
}, [(_a = options == null ? void 0 : options.creditLine) == null ? void 0 : _a.enabled, (_b = options == null ? void 0 : options.creditLine) == null ? void 0 : _b.excludeSources, options == null ? void 0 : options.maximumUploadSize]);
|
|
7263
|
+
return /* @__PURE__ */jsx(ToolOptionsContext.Provider, {
|
|
7264
|
+
value,
|
|
7265
|
+
children
|
|
7266
|
+
});
|
|
7267
|
+
};
|
|
7268
|
+
const useToolOptions = () => {
|
|
7269
|
+
const context = useContext(ToolOptionsContext);
|
|
7270
|
+
if (!context) {
|
|
7271
|
+
throw new Error("useToolOptions must be used within an ToolOptionsProvider");
|
|
7272
|
+
}
|
|
7273
|
+
return context;
|
|
7274
|
+
};
|
|
7230
7275
|
const SearchFacetsControl = () => {
|
|
7231
7276
|
const dispatch = useDispatch();
|
|
7232
7277
|
const assetTypes = useTypedSelector(state => state.assets.assetTypes);
|
|
7233
7278
|
const searchFacets = useTypedSelector(state => state.search.facets);
|
|
7234
7279
|
const selectedDocument = useTypedSelector(state => state.selected.document);
|
|
7235
7280
|
const popoverProps = usePortalPopoverProps();
|
|
7281
|
+
const {
|
|
7282
|
+
creditLine
|
|
7283
|
+
} = useToolOptions();
|
|
7236
7284
|
const isTool = !selectedDocument;
|
|
7237
7285
|
const filteredFacets = FACETS.filter(facet => {
|
|
7286
|
+
if (!(creditLine == null ? void 0 : creditLine.enabled) && (facet == null ? void 0 : facet.type) === "string" && (facet == null ? void 0 : facet.name) === "creditLine") {
|
|
7287
|
+
return false;
|
|
7288
|
+
}
|
|
7238
7289
|
if (facet.type === "group" || facet.type === "divider") {
|
|
7239
7290
|
return true;
|
|
7240
7291
|
}
|
|
@@ -7563,6 +7614,7 @@ const tagOptionSchema = z.object({
|
|
|
7563
7614
|
});
|
|
7564
7615
|
const assetFormSchema = z.object({
|
|
7565
7616
|
altText: z.string().trim().optional(),
|
|
7617
|
+
creditLine: z.string().trim().optional(),
|
|
7566
7618
|
description: z.string().trim().optional(),
|
|
7567
7619
|
opt: z.object({
|
|
7568
7620
|
media: z.object({
|
|
@@ -7620,11 +7672,11 @@ const isImageAsset = asset => {
|
|
|
7620
7672
|
const getAssetResolution = asset => {
|
|
7621
7673
|
return "".concat(asset.metadata.dimensions.width, "x").concat(asset.metadata.dimensions.height, "px");
|
|
7622
7674
|
};
|
|
7623
|
-
const ButtonAssetCopy =
|
|
7675
|
+
const ButtonAssetCopy = _ref44 => {
|
|
7624
7676
|
let {
|
|
7625
7677
|
disabled,
|
|
7626
7678
|
url
|
|
7627
|
-
} =
|
|
7679
|
+
} = _ref44;
|
|
7628
7680
|
const popoverProps = usePortalPopoverProps();
|
|
7629
7681
|
const refPopoverTimeout = useRef();
|
|
7630
7682
|
const [popoverVisible, setPopoverVisible] = useState(false);
|
|
@@ -7666,11 +7718,11 @@ const ButtonAssetCopy = _ref43 => {
|
|
|
7666
7718
|
})
|
|
7667
7719
|
});
|
|
7668
7720
|
};
|
|
7669
|
-
const Row =
|
|
7721
|
+
const Row = _ref45 => {
|
|
7670
7722
|
let {
|
|
7671
7723
|
label,
|
|
7672
7724
|
value
|
|
7673
|
-
} =
|
|
7725
|
+
} = _ref45;
|
|
7674
7726
|
return /* @__PURE__ */jsxs(Flex, {
|
|
7675
7727
|
justify: "space-between",
|
|
7676
7728
|
children: [/* @__PURE__ */jsx(Text, {
|
|
@@ -7781,11 +7833,11 @@ const Dialog = props => {
|
|
|
7781
7833
|
}
|
|
7782
7834
|
});
|
|
7783
7835
|
};
|
|
7784
|
-
const DocumentList =
|
|
7836
|
+
const DocumentList = _ref46 => {
|
|
7785
7837
|
let {
|
|
7786
7838
|
documents,
|
|
7787
7839
|
isLoading
|
|
7788
|
-
} =
|
|
7840
|
+
} = _ref46;
|
|
7789
7841
|
const schema = useSchema();
|
|
7790
7842
|
if (isLoading) {
|
|
7791
7843
|
return /* @__PURE__ */jsx(Text, {
|
|
@@ -7857,10 +7909,10 @@ var __template$c = (cooked, raw) => __freeze$c(__defProp$d(cooked, "raw", {
|
|
|
7857
7909
|
value: __freeze$c(raw || cooked.slice())
|
|
7858
7910
|
}));
|
|
7859
7911
|
var _a$c;
|
|
7860
|
-
const Container = styled(Box)(
|
|
7912
|
+
const Container = styled(Box)(_ref47 => {
|
|
7861
7913
|
let {
|
|
7862
7914
|
theme
|
|
7863
|
-
} =
|
|
7915
|
+
} = _ref47;
|
|
7864
7916
|
return css(_a$c || (_a$c = __template$c(["\n text {\n font-family: ", " !important;\n font-size: 8px !important;\n font-weight: 500 !important;\n }\n "])), theme.sanity.fonts.text.family);
|
|
7865
7917
|
});
|
|
7866
7918
|
const FileIcon = props => {
|
|
@@ -7928,10 +7980,10 @@ const {
|
|
|
7928
7980
|
} = studioTheme;
|
|
7929
7981
|
const reactSelectStyles = scheme => {
|
|
7930
7982
|
return {
|
|
7931
|
-
control: (styles,
|
|
7983
|
+
control: (styles, _ref48) => {
|
|
7932
7984
|
let {
|
|
7933
7985
|
isFocused
|
|
7934
|
-
} =
|
|
7986
|
+
} = _ref48;
|
|
7935
7987
|
let boxShadow = "inset 0 0 0 1px var(--card-border-color)";
|
|
7936
7988
|
if (isFocused) {
|
|
7937
7989
|
boxShadow = "inset 0 0 0 1px ".concat(getSchemeColor(scheme, "inputEnabledBorder"), ",\n 0 0 0 1px var(--card-bg-color),\n 0 0 0 3px var(--card-focus-ring-color) !important");
|
|
@@ -7953,10 +8005,10 @@ const reactSelectStyles = scheme => {
|
|
|
7953
8005
|
}
|
|
7954
8006
|
};
|
|
7955
8007
|
},
|
|
7956
|
-
indicatorsContainer: (styles,
|
|
8008
|
+
indicatorsContainer: (styles, _ref49) => {
|
|
7957
8009
|
let {
|
|
7958
8010
|
isDisabled
|
|
7959
|
-
} =
|
|
8011
|
+
} = _ref49;
|
|
7960
8012
|
return {
|
|
7961
8013
|
...styles,
|
|
7962
8014
|
opacity: isDisabled ? 0.25 : 1
|
|
@@ -7971,10 +8023,10 @@ const reactSelectStyles = scheme => {
|
|
|
7971
8023
|
menuList: styles => ({
|
|
7972
8024
|
...styles
|
|
7973
8025
|
}),
|
|
7974
|
-
multiValue: (styles,
|
|
8026
|
+
multiValue: (styles, _ref50) => {
|
|
7975
8027
|
let {
|
|
7976
8028
|
isDisabled
|
|
7977
|
-
} =
|
|
8029
|
+
} = _ref50;
|
|
7978
8030
|
return {
|
|
7979
8031
|
...styles,
|
|
7980
8032
|
backgroundColor: getSchemeColor(scheme, "mutedHoveredBg"),
|
|
@@ -8003,10 +8055,10 @@ const reactSelectStyles = scheme => {
|
|
|
8003
8055
|
fontFamily: studioTheme.fonts.text.family,
|
|
8004
8056
|
lineHeight: "1em"
|
|
8005
8057
|
}),
|
|
8006
|
-
option: (styles,
|
|
8058
|
+
option: (styles, _ref51) => {
|
|
8007
8059
|
let {
|
|
8008
8060
|
isFocused
|
|
8009
|
-
} =
|
|
8061
|
+
} = _ref51;
|
|
8010
8062
|
return {
|
|
8011
8063
|
...styles,
|
|
8012
8064
|
backgroundColor: isFocused ? getSchemeColor(scheme, "spotBlue") : "transparent",
|
|
@@ -8126,10 +8178,10 @@ const reactSelectComponents = {
|
|
|
8126
8178
|
MultiValueRemove,
|
|
8127
8179
|
Option
|
|
8128
8180
|
};
|
|
8129
|
-
const StyledErrorOutlineIcon = styled(ErrorOutlineIcon)(
|
|
8181
|
+
const StyledErrorOutlineIcon = styled(ErrorOutlineIcon)(_ref52 => {
|
|
8130
8182
|
let {
|
|
8131
8183
|
theme
|
|
8132
|
-
} =
|
|
8184
|
+
} = _ref52;
|
|
8133
8185
|
return {
|
|
8134
8186
|
color: theme.sanity.color.spot.red
|
|
8135
8187
|
};
|
|
@@ -8216,10 +8268,10 @@ const FormFieldInputTags = props => {
|
|
|
8216
8268
|
control,
|
|
8217
8269
|
defaultValue: value,
|
|
8218
8270
|
name,
|
|
8219
|
-
render:
|
|
8271
|
+
render: _ref53 => {
|
|
8220
8272
|
let {
|
|
8221
8273
|
field
|
|
8222
|
-
} =
|
|
8274
|
+
} = _ref53;
|
|
8223
8275
|
const {
|
|
8224
8276
|
onBlur,
|
|
8225
8277
|
onChange,
|
|
@@ -8390,9 +8442,13 @@ const DialogAssetEdit = props => {
|
|
|
8390
8442
|
const currentAsset = assetItem ? assetItem == null ? void 0 : assetItem.asset : assetSnapshot;
|
|
8391
8443
|
const allTagOptions = getTagSelectOptions(tags);
|
|
8392
8444
|
const assetTagOptions = useTypedSelector(selectTagSelectOptions(currentAsset));
|
|
8445
|
+
const {
|
|
8446
|
+
creditLine
|
|
8447
|
+
} = useToolOptions();
|
|
8393
8448
|
const generateDefaultValues = useCallback(asset => {
|
|
8394
8449
|
return {
|
|
8395
8450
|
altText: (asset == null ? void 0 : asset.altText) || "",
|
|
8451
|
+
creditLine: (asset == null ? void 0 : asset.creditLine) || "",
|
|
8396
8452
|
description: (asset == null ? void 0 : asset.description) || "",
|
|
8397
8453
|
originalFilename: (asset == null ? void 0 : asset.originalFilename) || "",
|
|
8398
8454
|
opt: {
|
|
@@ -8550,12 +8606,12 @@ const DialogAssetEdit = props => {
|
|
|
8550
8606
|
children: /* @__PURE__ */jsx(WithReferringDocuments, {
|
|
8551
8607
|
documentStore,
|
|
8552
8608
|
id: currentAsset._id,
|
|
8553
|
-
children:
|
|
8609
|
+
children: _ref54 => {
|
|
8554
8610
|
let {
|
|
8555
8611
|
isLoading,
|
|
8556
8612
|
referringDocuments
|
|
8557
|
-
} =
|
|
8558
|
-
var _a3, _b, _c, _d, _e, _f, _g;
|
|
8613
|
+
} = _ref54;
|
|
8614
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
8559
8615
|
const uniqueReferringDocuments = getUniqueDocuments(referringDocuments);
|
|
8560
8616
|
return /* @__PURE__ */jsxs(Fragment, {
|
|
8561
8617
|
children: [/* @__PURE__ */jsxs(TabList, {
|
|
@@ -8642,6 +8698,13 @@ const DialogAssetEdit = props => {
|
|
|
8642
8698
|
name: "description",
|
|
8643
8699
|
rows: 5,
|
|
8644
8700
|
value: currentAsset == null ? void 0 : currentAsset.description
|
|
8701
|
+
}), (creditLine == null ? void 0 : creditLine.enabled) && /* @__PURE__ */jsx(FormFieldInputText, {
|
|
8702
|
+
...register("creditLine"),
|
|
8703
|
+
error: (_h = errors == null ? void 0 : errors.creditLine) == null ? void 0 : _h.message,
|
|
8704
|
+
label: "Credit",
|
|
8705
|
+
name: "creditLine",
|
|
8706
|
+
value: currentAsset == null ? void 0 : currentAsset.creditLine,
|
|
8707
|
+
disabled: formUpdating || ((_j = creditLine == null ? void 0 : creditLine.excludeSources) == null ? void 0 : _j.includes((_i = currentAsset == null ? void 0 : currentAsset.source) == null ? void 0 : _i.name))
|
|
8645
8708
|
})]
|
|
8646
8709
|
})
|
|
8647
8710
|
}), /* @__PURE__ */jsx(TabPanel, {
|
|
@@ -9190,11 +9253,11 @@ const Tag = props => {
|
|
|
9190
9253
|
})]
|
|
9191
9254
|
});
|
|
9192
9255
|
};
|
|
9193
|
-
const VirtualRow$1 = memo(
|
|
9256
|
+
const VirtualRow$1 = memo(_ref55 => {
|
|
9194
9257
|
let {
|
|
9195
9258
|
isScrolling,
|
|
9196
9259
|
item
|
|
9197
|
-
} =
|
|
9260
|
+
} = _ref55;
|
|
9198
9261
|
var _a;
|
|
9199
9262
|
if (typeof item === "string") {
|
|
9200
9263
|
return /* @__PURE__ */jsx(Flex, {
|
|
@@ -9300,12 +9363,12 @@ const TagsVirtualized = () => {
|
|
|
9300
9363
|
totalCount: items.length
|
|
9301
9364
|
});
|
|
9302
9365
|
};
|
|
9303
|
-
const TagViewHeader =
|
|
9366
|
+
const TagViewHeader = _ref56 => {
|
|
9304
9367
|
let {
|
|
9305
9368
|
allowCreate,
|
|
9306
9369
|
light,
|
|
9307
9370
|
title
|
|
9308
|
-
} =
|
|
9371
|
+
} = _ref56;
|
|
9309
9372
|
const {
|
|
9310
9373
|
scheme
|
|
9311
9374
|
} = useColorScheme();
|
|
@@ -9602,24 +9665,24 @@ var __template$7 = (cooked, raw) => __freeze$7(__defProp$8(cooked, "raw", {
|
|
|
9602
9665
|
}));
|
|
9603
9666
|
var _a$7, _b$4, _c$1, _d;
|
|
9604
9667
|
const CardWrapper$1 = styled(Flex)(_a$7 || (_a$7 = __template$7(["\n box-sizing: border-box;\n height: 100%;\n overflow: hidden;\n position: relative;\n width: 100%;\n"])));
|
|
9605
|
-
const CardContainer = styled(Flex)(
|
|
9668
|
+
const CardContainer = styled(Flex)(_ref57 => {
|
|
9606
9669
|
let {
|
|
9607
9670
|
picked,
|
|
9608
9671
|
theme,
|
|
9609
9672
|
updating
|
|
9610
|
-
} =
|
|
9673
|
+
} = _ref57;
|
|
9611
9674
|
return css(_c$1 || (_c$1 = __template$7(["\n border: 1px solid transparent;\n height: 100%;\n pointer-events: ", ";\n position: relative;\n transition: all 300ms;\n user-select: none;\n width: 100%;\n\n border: ", ";\n\n ", "\n "])), updating ? "none" : "auto", picked ? "1px solid ".concat(theme.sanity.color.spot.orange, " !important") : "1px solid inherit", !updating && css(_b$4 || (_b$4 = __template$7(["\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n border: 1px solid var(--card-border-color);\n }\n }\n "]))));
|
|
9612
9675
|
});
|
|
9613
|
-
const ContextActionContainer$2 = styled(Flex)(
|
|
9676
|
+
const ContextActionContainer$2 = styled(Flex)(_ref58 => {
|
|
9614
9677
|
let {
|
|
9615
9678
|
scheme
|
|
9616
|
-
} =
|
|
9679
|
+
} = _ref58;
|
|
9617
9680
|
return css(_d || (_d = __template$7(["\n cursor: pointer;\n height: ", "px;\n transition: all 300ms;\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ", ";\n }\n }\n "])), PANEL_HEIGHT, getSchemeColor(scheme, "bg"));
|
|
9618
9681
|
});
|
|
9619
|
-
const StyledWarningOutlineIcon = styled(WarningFilledIcon)(
|
|
9682
|
+
const StyledWarningOutlineIcon = styled(WarningFilledIcon)(_ref59 => {
|
|
9620
9683
|
let {
|
|
9621
9684
|
theme
|
|
9622
|
-
} =
|
|
9685
|
+
} = _ref59;
|
|
9623
9686
|
return {
|
|
9624
9687
|
color: theme.sanity.color.spot.red
|
|
9625
9688
|
};
|
|
@@ -10050,10 +10113,10 @@ const uploadsSlice = createSlice({
|
|
|
10050
10113
|
}
|
|
10051
10114
|
}
|
|
10052
10115
|
});
|
|
10053
|
-
const uploadsAssetStartEpic = (action$, _state$,
|
|
10116
|
+
const uploadsAssetStartEpic = (action$, _state$, _ref60) => {
|
|
10054
10117
|
let {
|
|
10055
10118
|
client
|
|
10056
|
-
} =
|
|
10119
|
+
} = _ref60;
|
|
10057
10120
|
return action$.pipe(filter(uploadsActions.uploadStart.match), mergeMap(action => {
|
|
10058
10121
|
const {
|
|
10059
10122
|
file,
|
|
@@ -10092,8 +10155,8 @@ const uploadsAssetStartEpic = (action$, _state$, _ref59) => {
|
|
|
10092
10155
|
})))));
|
|
10093
10156
|
}));
|
|
10094
10157
|
};
|
|
10095
|
-
const uploadsAssetUploadEpic = (action$, state$) => action$.pipe(filter(uploadsActions.uploadRequest.match), withLatestFrom(state$), mergeMap(
|
|
10096
|
-
let [action, state] =
|
|
10158
|
+
const uploadsAssetUploadEpic = (action$, state$) => action$.pipe(filter(uploadsActions.uploadRequest.match), withLatestFrom(state$), mergeMap(_ref61 => {
|
|
10159
|
+
let [action, state] = _ref61;
|
|
10097
10160
|
const {
|
|
10098
10161
|
file,
|
|
10099
10162
|
forceAsAssetType
|
|
@@ -10129,12 +10192,12 @@ const uploadsCompleteQueueEpic = action$ => action$.pipe(filter(UPLOADS_ACTIONS.
|
|
|
10129
10192
|
assets: [action.payload.asset]
|
|
10130
10193
|
}));
|
|
10131
10194
|
}));
|
|
10132
|
-
const uploadsCheckRequestEpic = (action$, state$,
|
|
10195
|
+
const uploadsCheckRequestEpic = (action$, state$, _ref62) => {
|
|
10133
10196
|
let {
|
|
10134
10197
|
client
|
|
10135
|
-
} =
|
|
10136
|
-
return action$.pipe(filter(uploadsActions.checkRequest.match), withLatestFrom(state$), mergeMap(
|
|
10137
|
-
let [action, state] =
|
|
10198
|
+
} = _ref62;
|
|
10199
|
+
return action$.pipe(filter(uploadsActions.checkRequest.match), withLatestFrom(state$), mergeMap(_ref63 => {
|
|
10200
|
+
let [action, state] = _ref63;
|
|
10138
10201
|
const {
|
|
10139
10202
|
assets
|
|
10140
10203
|
} = action.payload;
|
|
@@ -10314,11 +10377,11 @@ var __template$4 = (cooked, raw) => __freeze$4(__defProp$5(cooked, "raw", {
|
|
|
10314
10377
|
var _a$4, _b$3;
|
|
10315
10378
|
const CARD_HEIGHT = 220;
|
|
10316
10379
|
const CARD_WIDTH = 240;
|
|
10317
|
-
const VirtualCell = memo(
|
|
10380
|
+
const VirtualCell = memo(_ref64 => {
|
|
10318
10381
|
let {
|
|
10319
10382
|
item,
|
|
10320
10383
|
selected
|
|
10321
|
-
} =
|
|
10384
|
+
} = _ref64;
|
|
10322
10385
|
if ((item == null ? void 0 : item.type) === "asset") {
|
|
10323
10386
|
return /* @__PURE__ */jsx(CardAsset$1, {
|
|
10324
10387
|
id: item.id,
|
|
@@ -10426,10 +10489,10 @@ var __template$3 = (cooked, raw) => __freeze$3(__defProp$4(cooked, "raw", {
|
|
|
10426
10489
|
value: __freeze$3(raw || cooked.slice())
|
|
10427
10490
|
}));
|
|
10428
10491
|
var _a$3;
|
|
10429
|
-
const ContextActionContainer$1 = styled(Flex)(
|
|
10492
|
+
const ContextActionContainer$1 = styled(Flex)(_ref65 => {
|
|
10430
10493
|
let {
|
|
10431
10494
|
scheme
|
|
10432
|
-
} =
|
|
10495
|
+
} = _ref65;
|
|
10433
10496
|
return css(_a$3 || (_a$3 = __template$3(["\n cursor: pointer;\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ", ";\n }\n }\n "])), getSchemeColor(scheme, "bg"));
|
|
10434
10497
|
});
|
|
10435
10498
|
const TableHeader = () => {
|
|
@@ -10515,24 +10578,24 @@ var __template$2 = (cooked, raw) => __freeze$2(__defProp$3(cooked, "raw", {
|
|
|
10515
10578
|
}));
|
|
10516
10579
|
var _a$2, _b$2, _c;
|
|
10517
10580
|
const REFERENCE_COUNT_VISIBILITY_DELAY = 750;
|
|
10518
|
-
const ContainerGrid = styled(Grid)(
|
|
10581
|
+
const ContainerGrid = styled(Grid)(_ref66 => {
|
|
10519
10582
|
let {
|
|
10520
10583
|
scheme,
|
|
10521
10584
|
selected,
|
|
10522
10585
|
updating
|
|
10523
|
-
} =
|
|
10586
|
+
} = _ref66;
|
|
10524
10587
|
return css(_b$2 || (_b$2 = __template$2(["\n align-items: center;\n cursor: ", ";\n height: 100%;\n pointer-events: ", ";\n user-select: none;\n white-space: nowrap;\n\n ", "\n "])), selected ? "default" : "pointer", updating ? "none" : "auto", !updating && css(_a$2 || (_a$2 = __template$2(["\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ", ";\n }\n }\n "])), getSchemeColor(scheme, "bg")));
|
|
10525
10588
|
});
|
|
10526
|
-
const ContextActionContainer = styled(Flex)(
|
|
10589
|
+
const ContextActionContainer = styled(Flex)(_ref67 => {
|
|
10527
10590
|
let {
|
|
10528
10591
|
scheme
|
|
10529
|
-
} =
|
|
10592
|
+
} = _ref67;
|
|
10530
10593
|
return css(_c || (_c = __template$2(["\n cursor: pointer;\n @media (hover: hover) and (pointer: fine) {\n &:hover {\n background: ", ";\n }\n }\n "])), getSchemeColor(scheme, "bg2"));
|
|
10531
10594
|
});
|
|
10532
|
-
const StyledWarningIcon = styled(WarningFilledIcon)(
|
|
10595
|
+
const StyledWarningIcon = styled(WarningFilledIcon)(_ref68 => {
|
|
10533
10596
|
let {
|
|
10534
10597
|
theme
|
|
10535
|
-
} =
|
|
10598
|
+
} = _ref68;
|
|
10536
10599
|
return {
|
|
10537
10600
|
color: theme.sanity.color.spot.red
|
|
10538
10601
|
};
|
|
@@ -10816,11 +10879,11 @@ const TableRowAsset = props => {
|
|
|
10816
10879
|
textOverflow: "ellipsis",
|
|
10817
10880
|
children: referenceCountVisible ? /* @__PURE__ */jsx(WithReferringDocuments, {
|
|
10818
10881
|
id,
|
|
10819
|
-
children:
|
|
10882
|
+
children: _ref69 => {
|
|
10820
10883
|
let {
|
|
10821
10884
|
isLoading,
|
|
10822
10885
|
referringDocuments
|
|
10823
|
-
} =
|
|
10886
|
+
} = _ref69;
|
|
10824
10887
|
const uniqueDocuments = getUniqueDocuments(referringDocuments);
|
|
10825
10888
|
return isLoading ? /* @__PURE__ */jsx(Fragment, {
|
|
10826
10889
|
children: "-"
|
|
@@ -11000,11 +11063,11 @@ const TableRowUpload = props => {
|
|
|
11000
11063
|
})]
|
|
11001
11064
|
});
|
|
11002
11065
|
};
|
|
11003
|
-
const VirtualRow = memo(
|
|
11066
|
+
const VirtualRow = memo(_ref70 => {
|
|
11004
11067
|
let {
|
|
11005
11068
|
item,
|
|
11006
11069
|
selected
|
|
11007
|
-
} =
|
|
11070
|
+
} = _ref70;
|
|
11008
11071
|
if ((item == null ? void 0 : item.type) === "asset") {
|
|
11009
11072
|
return /* @__PURE__ */jsx(Box, {
|
|
11010
11073
|
style: {
|
|
@@ -11411,29 +11474,6 @@ const TagsPanel = () => {
|
|
|
11411
11474
|
})
|
|
11412
11475
|
});
|
|
11413
11476
|
};
|
|
11414
|
-
const ToolOptionsContext = createContext(null);
|
|
11415
|
-
const ToolOptionsProvider = _ref70 => {
|
|
11416
|
-
let {
|
|
11417
|
-
options,
|
|
11418
|
-
children
|
|
11419
|
-
} = _ref70;
|
|
11420
|
-
const value = useMemo(() => ({
|
|
11421
|
-
dropzone: {
|
|
11422
|
-
maxSize: options == null ? void 0 : options.maximumUploadSize
|
|
11423
|
-
}
|
|
11424
|
-
}), [options == null ? void 0 : options.maximumUploadSize]);
|
|
11425
|
-
return /* @__PURE__ */jsx(ToolOptionsContext.Provider, {
|
|
11426
|
-
value,
|
|
11427
|
-
children
|
|
11428
|
-
});
|
|
11429
|
-
};
|
|
11430
|
-
const useToolOptions = () => {
|
|
11431
|
-
const context = useContext(ToolOptionsContext);
|
|
11432
|
-
if (!context) {
|
|
11433
|
-
throw new Error("useToolOptions must be used within an ToolOptionsProvider");
|
|
11434
|
-
}
|
|
11435
|
-
return context;
|
|
11436
|
-
};
|
|
11437
11477
|
var __freeze$1 = Object.freeze;
|
|
11438
11478
|
var __defProp$1 = Object.defineProperty;
|
|
11439
11479
|
var __template$1 = (cooked, raw) => __freeze$1(__defProp$1(cooked, "raw", {
|
|
@@ -11731,20 +11771,12 @@ const useRootPortalElement = () => {
|
|
|
11731
11771
|
}, [container]);
|
|
11732
11772
|
return container;
|
|
11733
11773
|
};
|
|
11734
|
-
const Tool =
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
return /* @__PURE__ */jsx(ToolOptionsProvider, {
|
|
11741
|
-
options,
|
|
11742
|
-
children: /* @__PURE__ */jsx(Flex, {
|
|
11743
|
-
direction: "column",
|
|
11744
|
-
height: "fill",
|
|
11745
|
-
flex: 1,
|
|
11746
|
-
children: /* @__PURE__ */jsx(Browser, {})
|
|
11747
|
-
})
|
|
11774
|
+
const Tool = () => {
|
|
11775
|
+
return /* @__PURE__ */jsx(Flex, {
|
|
11776
|
+
direction: "column",
|
|
11777
|
+
height: "fill",
|
|
11778
|
+
flex: 1,
|
|
11779
|
+
children: /* @__PURE__ */jsx(Browser, {})
|
|
11748
11780
|
});
|
|
11749
11781
|
};
|
|
11750
11782
|
var mediaTag = {
|
|
@@ -11781,8 +11813,20 @@ const mediaAssetSource = {
|
|
|
11781
11813
|
...plugin,
|
|
11782
11814
|
component: FormBuilderTool
|
|
11783
11815
|
};
|
|
11816
|
+
const tool = {
|
|
11817
|
+
...plugin,
|
|
11818
|
+
component: Tool
|
|
11819
|
+
};
|
|
11784
11820
|
const media = definePlugin(options => ({
|
|
11785
11821
|
name: "media",
|
|
11822
|
+
studio: {
|
|
11823
|
+
components: {
|
|
11824
|
+
layout: props => /* @__PURE__ */jsx(ToolOptionsProvider, {
|
|
11825
|
+
options,
|
|
11826
|
+
children: props.renderDefault(props)
|
|
11827
|
+
})
|
|
11828
|
+
}
|
|
11829
|
+
},
|
|
11786
11830
|
form: {
|
|
11787
11831
|
file: {
|
|
11788
11832
|
assetSources: prev => {
|
|
@@ -11799,11 +11843,7 @@ const media = definePlugin(options => ({
|
|
|
11799
11843
|
types: [mediaTag]
|
|
11800
11844
|
},
|
|
11801
11845
|
tools: prev => {
|
|
11802
|
-
return [...prev,
|
|
11803
|
-
...plugin,
|
|
11804
|
-
options,
|
|
11805
|
-
component: Tool
|
|
11806
|
-
}];
|
|
11846
|
+
return [...prev, tool];
|
|
11807
11847
|
}
|
|
11808
11848
|
}));
|
|
11809
11849
|
export { media, mediaAssetSource };
|