sanity-plugin-media 2.4.1 → 2.4.2-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +44 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -11
- package/src/components/AssetGridVirtualized/index.tsx +0 -1
- package/src/components/Browser/index.tsx +2 -2
- package/src/components/ButtonAssetCopy/index.tsx +1 -1
- package/src/components/CardAsset/index.tsx +2 -2
- package/src/components/CardUpload/index.tsx +2 -3
- package/src/components/DialogAssetEdit/index.tsx +2 -2
- package/src/components/FormFieldInputTags/index.tsx +2 -3
- package/src/components/PickedBar/index.tsx +2 -3
- package/src/components/SearchFacet/index.tsx +2 -2
- package/src/components/SearchFacetTags/index.tsx +3 -4
- package/src/components/TableHeader/index.tsx +2 -2
- package/src/components/TableRowAsset/index.tsx +3 -3
- package/src/components/TableRowUpload/index.tsx +2 -3
- package/src/components/TagViewHeader/index.tsx +2 -3
- package/src/styled/react-select/creatable.tsx +6 -0
- package/src/styled/react-select/single.tsx +6 -0
package/dist/index.js
CHANGED
|
@@ -1808,7 +1808,7 @@ const Container$1 = styledComponents.styled(ui.Box)(({ scheme, theme }) => style
|
|
|
1808
1808
|
background: ${getSchemeColor(scheme, "bg")};
|
|
1809
1809
|
border-radius: ${ui.rem(theme.sanity.radius[2])};
|
|
1810
1810
|
`), SearchFacet = (props) => {
|
|
1811
|
-
const { children, facet } = props,
|
|
1811
|
+
const { children, facet } = props, scheme = sanity.useColorSchemeValue(), dispatch = reactRedux.useDispatch(), handleClose = () => {
|
|
1812
1812
|
dispatch(searchActions.facetsRemoveById({ facetId: facet.id }));
|
|
1813
1813
|
};
|
|
1814
1814
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2113,16 +2113,22 @@ const Container$1 = styledComponents.styled(ui.Box)(({ scheme, theme }) => style
|
|
|
2113
2113
|
margin: 0,
|
|
2114
2114
|
padding: 0
|
|
2115
2115
|
})
|
|
2116
|
-
}), ClearIndicator = (props) =>
|
|
2117
|
-
|
|
2118
|
-
{
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2116
|
+
}), ClearIndicator = (props) => (
|
|
2117
|
+
// @ts-expect-error - fix typings later
|
|
2118
|
+
/* @__PURE__ */ jsxRuntime.jsx(Select.components.ClearIndicator, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2119
|
+
ui.Box,
|
|
2120
|
+
{
|
|
2121
|
+
paddingRight: 1,
|
|
2122
|
+
style: {
|
|
2123
|
+
transform: "scale(0.85)"
|
|
2124
|
+
},
|
|
2125
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 0, children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseIcon, {}) })
|
|
2126
|
+
}
|
|
2127
|
+
) })
|
|
2128
|
+
), Menu$1 = (props) => (
|
|
2129
|
+
// @ts-expect-error - fix typings later
|
|
2130
|
+
/* @__PURE__ */ jsxRuntime.jsx(Select.components.Menu, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 1, shadow: 2, children: props.children }) })
|
|
2131
|
+
), MenuList$1 = (props) => {
|
|
2126
2132
|
const { children } = props, MAX_ROWS = 5, OPTION_HEIGHT = 33;
|
|
2127
2133
|
if (Array.isArray(children)) {
|
|
2128
2134
|
const height = children.length > MAX_ROWS ? OPTION_HEIGHT * MAX_ROWS : children.length * OPTION_HEIGHT;
|
|
@@ -2140,7 +2146,10 @@ const Container$1 = styledComponents.styled(ui.Box)(({ scheme, theme }) => style
|
|
|
2140
2146
|
);
|
|
2141
2147
|
}
|
|
2142
2148
|
return /* @__PURE__ */ jsxRuntime.jsx(Select.components.MenuList, { ...props, children });
|
|
2143
|
-
}, NoOptionsMessage = (props) => /* @__PURE__ */ jsxRuntime.jsx(Select.components.NoOptionsMessage, { ...props, children: props.children }), Option$1 = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.Option, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingY: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: { color: "inherit" }, textOverflow: "ellipsis", children: props.children }) }) }) }), SingleValue = (props) =>
|
|
2149
|
+
}, NoOptionsMessage = (props) => /* @__PURE__ */ jsxRuntime.jsx(Select.components.NoOptionsMessage, { ...props, children: props.children }), Option$1 = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.Option, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingY: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: { color: "inherit" }, textOverflow: "ellipsis", children: props.children }) }) }) }), SingleValue = (props) => (
|
|
2150
|
+
// @ts-expect-error - fix typings later
|
|
2151
|
+
/* @__PURE__ */ jsxRuntime.jsx(Select.components.SingleValue, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, textOverflow: "ellipsis", children: props.children }) })
|
|
2152
|
+
), reactSelectComponents$1 = {
|
|
2144
2153
|
ClearIndicator,
|
|
2145
2154
|
DropdownIndicator: null,
|
|
2146
2155
|
IndicatorSeparator: null,
|
|
@@ -2150,7 +2159,7 @@ const Container$1 = styledComponents.styled(ui.Box)(({ scheme, theme }) => style
|
|
|
2150
2159
|
Option: Option$1,
|
|
2151
2160
|
SingleValue
|
|
2152
2161
|
}, SearchFacetTags = ({ facet }) => {
|
|
2153
|
-
const
|
|
2162
|
+
const scheme = sanity.useColorSchemeValue(), dispatch = reactRedux.useDispatch(), tags = useTypedSelector((state) => selectTags(state)), tagsFetching = useTypedSelector((state) => state.tags.fetching), allTagOptions = getTagSelectOptions(tags), popoverProps = usePortalPopoverProps(), handleChange = (option) => {
|
|
2154
2163
|
dispatch(
|
|
2155
2164
|
searchActions.facetsUpdateById({
|
|
2156
2165
|
id: facet.id,
|
|
@@ -2551,7 +2560,7 @@ const imageDprUrl = (asset, options) => {
|
|
|
2551
2560
|
const val = formData[key];
|
|
2552
2561
|
return typeof val == "object" && val !== null && val.constructor !== Array ? acc[key] = sanitizeFormData(val) : val === "" || typeof val > "u" || val?.length === 0 ? acc[key] = null : typeof val == "string" && val ? acc[key] = formData[key].trim() : acc[key] = formData[key], acc;
|
|
2553
2562
|
}, {}), isFileAsset = (asset) => asset._type === "sanity.fileAsset", isImageAsset = (asset) => asset._type === "sanity.imageAsset", getAssetResolution = (asset) => `${asset.metadata.dimensions.width}x${asset.metadata.dimensions.height}px`, ButtonAssetCopy = ({ disabled, url }) => {
|
|
2554
|
-
const popoverProps = usePortalPopoverProps(), refPopoverTimeout = react.useRef(), [popoverVisible, setPopoverVisible] = react.useState(!1), handleClick = () => {
|
|
2563
|
+
const popoverProps = usePortalPopoverProps(), refPopoverTimeout = react.useRef(null), [popoverVisible, setPopoverVisible] = react.useState(!1), handleClick = () => {
|
|
2555
2564
|
refPopoverTimeout.current && clearTimeout(refPopoverTimeout.current), setPopoverVisible(!0), copy__default.default(url), refPopoverTimeout.current = setTimeout(() => {
|
|
2556
2565
|
setPopoverVisible(!1);
|
|
2557
2566
|
}, 1250);
|
|
@@ -2787,7 +2796,13 @@ const imageDprUrl = (asset, options) => {
|
|
|
2787
2796
|
margin: 0,
|
|
2788
2797
|
padding: 0
|
|
2789
2798
|
})
|
|
2790
|
-
}), DropdownIndicator = (props) =>
|
|
2799
|
+
}), DropdownIndicator = (props) => (
|
|
2800
|
+
// @ts-expect-error - fix typings later
|
|
2801
|
+
/* @__PURE__ */ jsxRuntime.jsx(Select.components.DropdownIndicator, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingX: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDownIcon, {}) }) }) })
|
|
2802
|
+
), Menu = (props) => (
|
|
2803
|
+
// @ts-expect-error - fix typings later
|
|
2804
|
+
/* @__PURE__ */ jsxRuntime.jsx(Select.components.Menu, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 1, shadow: 2, children: props.children }) })
|
|
2805
|
+
), MenuList = (props) => {
|
|
2791
2806
|
const { children } = props, MAX_ROWS = 5, OPTION_HEIGHT = 37;
|
|
2792
2807
|
if (Array.isArray(children)) {
|
|
2793
2808
|
const height = children.length > MAX_ROWS ? OPTION_HEIGHT * MAX_ROWS : children.length * OPTION_HEIGHT;
|
|
@@ -2805,7 +2820,10 @@ const imageDprUrl = (asset, options) => {
|
|
|
2805
2820
|
);
|
|
2806
2821
|
}
|
|
2807
2822
|
return /* @__PURE__ */ jsxRuntime.jsx(Select.components.MenuList, { ...props, children });
|
|
2808
|
-
}, MultiValueLabel = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 2, paddingRight: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "medium", children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.MultiValueLabel, { ...props }) }) }), MultiValueRemove = (props) =>
|
|
2823
|
+
}, MultiValueLabel = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 2, paddingRight: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "medium", children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.MultiValueLabel, { ...props }) }) }), MultiValueRemove = (props) => (
|
|
2824
|
+
// @ts-expect-error - fix typings later
|
|
2825
|
+
/* @__PURE__ */ jsxRuntime.jsx(Select.components.MultiValueRemove, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseIcon, { color: "#1f2123" }) })
|
|
2826
|
+
), Option = (props) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { paddingX: 1, paddingY: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Select.components.Option, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", children: [
|
|
2809
2827
|
props.data.__isNew__ && /* @__PURE__ */ jsxRuntime.jsx(icons.AddIcon, { style: { marginRight: "3px" } }),
|
|
2810
2828
|
props.children
|
|
2811
2829
|
] }) }) }), reactSelectComponents = {
|
|
@@ -2851,7 +2869,7 @@ const imageDprUrl = (asset, options) => {
|
|
|
2851
2869
|
options,
|
|
2852
2870
|
placeholder,
|
|
2853
2871
|
value
|
|
2854
|
-
} = props,
|
|
2872
|
+
} = props, scheme = sanity.useColorSchemeValue(), creating = useTypedSelector((state) => state.tags.creating), tagsFetching = useTypedSelector((state) => state.tags.fetching);
|
|
2855
2873
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2856
2874
|
ui.Box,
|
|
2857
2875
|
{
|
|
@@ -2977,7 +2995,7 @@ const imageDprUrl = (asset, options) => {
|
|
|
2977
2995
|
const {
|
|
2978
2996
|
children,
|
|
2979
2997
|
dialog: { assetId, id, lastCreatedTag, lastRemovedTagIds }
|
|
2980
|
-
} = props, client = useVersionedClient(),
|
|
2998
|
+
} = props, client = useVersionedClient(), scheme = sanity.useColorSchemeValue(), documentStore = sanity.useDocumentStore(), dispatch = reactRedux.useDispatch(), assetItem = useTypedSelector((state) => selectAssetById(state, String(assetId))), tags = useTypedSelector(selectTags), assetUpdatedPrev = react.useRef(void 0), [assetSnapshot, setAssetSnapshot] = react.useState(assetItem?.asset), [tabSection, setTabSection] = react.useState("details"), currentAsset = assetItem ? assetItem?.asset : assetSnapshot, allTagOptions = getTagSelectOptions(tags), assetTagOptions = useTypedSelector(selectTagSelectOptions(currentAsset)), { creditLine } = useToolOptions(), generateDefaultValues = react.useCallback(
|
|
2981
2999
|
(asset) => ({
|
|
2982
3000
|
altText: asset?.altText || "",
|
|
2983
3001
|
creditLine: asset?.creditLine || "",
|
|
@@ -3629,7 +3647,7 @@ const imageDprUrl = (asset, options) => {
|
|
|
3629
3647
|
}
|
|
3630
3648
|
);
|
|
3631
3649
|
}, TagViewHeader = ({ allowCreate, light, title }) => {
|
|
3632
|
-
const
|
|
3650
|
+
const scheme = sanity.useColorSchemeValue(), dispatch = reactRedux.useDispatch(), tagsCreating = useTypedSelector((state) => state.tags.creating), tagsFetching = useTypedSelector((state) => state.tags.fetching), handleTagCreate = () => {
|
|
3633
3651
|
dispatch(DIALOG_ACTIONS.showTagCreate());
|
|
3634
3652
|
};
|
|
3635
3653
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3829,7 +3847,7 @@ const imageDprUrl = (asset, options) => {
|
|
|
3829
3847
|
), StyledWarningOutlineIcon = styledComponents.styled(icons.WarningFilledIcon)(({ theme }) => ({
|
|
3830
3848
|
color: theme.sanity.color.spot.red
|
|
3831
3849
|
})), CardAsset = (props) => {
|
|
3832
|
-
const { id, selected } = props,
|
|
3850
|
+
const { id, selected } = props, scheme = sanity.useColorSchemeValue(), shiftPressed = useKeyPress("shift"), dispatch = reactRedux.useDispatch(), lastPicked = useTypedSelector((state) => state.assets.lastPicked), item = useTypedSelector((state) => selectAssetById(state, id)), asset = item?.asset, error = item?.error, isOpaque = item?.asset?.metadata?.isOpaque, picked = item?.picked, updating = item?.updating, { onSelect } = useAssetSourceActions();
|
|
3833
3851
|
if (!asset)
|
|
3834
3852
|
return null;
|
|
3835
3853
|
const handleAssetClick = (e) => {
|
|
@@ -4214,7 +4232,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
|
|
|
4214
4232
|
position: relative;
|
|
4215
4233
|
width: 100%;
|
|
4216
4234
|
`, CardUpload = (props) => {
|
|
4217
|
-
const { id } = props,
|
|
4235
|
+
const { id } = props, scheme = sanity.useColorSchemeValue(), dispatch = reactRedux.useDispatch(), item = useTypedSelector((state) => selectUploadById(state, id));
|
|
4218
4236
|
if (!item)
|
|
4219
4237
|
return null;
|
|
4220
4238
|
const fileSize = filesize__default.default(item.size, { base: 10, round: 0 }), percentLoaded = Math.round(item.percent || 0), isComplete = item.status === "complete", isUploading = item.status === "uploading", isQueued = item.status === "queued";
|
|
@@ -4333,7 +4351,6 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
|
|
|
4333
4351
|
computeItemKey: (index) => items[index]?.id,
|
|
4334
4352
|
components: {
|
|
4335
4353
|
Item: ItemContainer,
|
|
4336
|
-
// @ts-expect-error - fix typings later
|
|
4337
4354
|
List: ListContainer
|
|
4338
4355
|
},
|
|
4339
4356
|
endReached: onLoadMore,
|
|
@@ -4390,7 +4407,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
|
|
|
4390
4407
|
}
|
|
4391
4408
|
`
|
|
4392
4409
|
), TableHeader = () => {
|
|
4393
|
-
const
|
|
4410
|
+
const scheme = sanity.useColorSchemeValue(), dispatch = reactRedux.useDispatch(), fetching = useTypedSelector((state) => state.assets.fetching), itemsLength = useTypedSelector(selectAssetsLength), numPickedAssets = useTypedSelector(selectAssetsPickedLength), mediaIndex = ui.useMediaIndex(), { onSelect } = useAssetSourceActions(), allSelected = numPickedAssets === itemsLength, handleContextActionClick = (e) => {
|
|
4394
4411
|
e.stopPropagation(), dispatch(allSelected ? assetsActions.pickClear() : assetsActions.pickAll());
|
|
4395
4412
|
};
|
|
4396
4413
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -4481,7 +4498,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
|
|
|
4481
4498
|
`), StyledWarningIcon = styledComponents.styled(icons.WarningFilledIcon)(({ theme }) => ({
|
|
4482
4499
|
color: theme.sanity.color.spot.red
|
|
4483
4500
|
})), TableRowAsset = (props) => {
|
|
4484
|
-
const { id, selected } = props,
|
|
4501
|
+
const { id, selected } = props, scheme = sanity.useColorSchemeValue(), shiftPressed = useKeyPress("shift"), [referenceCountVisible, setReferenceCountVisible] = react.useState(!1), refCountVisibleTimeout = react.useRef(null), dispatch = reactRedux.useDispatch(), lastPicked = useTypedSelector((state) => state.assets.lastPicked), item = useTypedSelector((state) => selectAssetById(state, id)), mediaIndex = ui.useMediaIndex(), asset = item?.asset, error = item?.error, isOpaque = item?.asset?.metadata?.isOpaque, picked = item?.picked, updating = item?.updating, { onSelect } = useAssetSourceActions(), handleContextActionClick = react.useCallback(
|
|
4485
4502
|
(e) => {
|
|
4486
4503
|
e.stopPropagation(), asset && (onSelect ? dispatch(dialogActions.showAssetEdit({ assetId: asset._id })) : shiftPressed.current && !picked ? dispatch(assetsActions.pickRange({ startId: lastPicked || asset._id, endId: asset._id })) : dispatch(assetsActions.pick({ assetId: asset._id, picked: !picked })));
|
|
4487
4504
|
},
|
|
@@ -4707,7 +4724,7 @@ const CardWrapper = styledComponents.styled(ui.Flex)`
|
|
|
4707
4724
|
};
|
|
4708
4725
|
var TableRowAsset$1 = react.memo(TableRowAsset);
|
|
4709
4726
|
const TableRowUpload = (props) => {
|
|
4710
|
-
const { id } = props,
|
|
4727
|
+
const { id } = props, scheme = sanity.useColorSchemeValue(), dispatch = reactRedux.useDispatch(), item = useTypedSelector((state) => selectUploadById(state, id)), mediaIndex = ui.useMediaIndex();
|
|
4711
4728
|
if (!item)
|
|
4712
4729
|
return null;
|
|
4713
4730
|
const fileSize = filesize__default.default(item.size, { base: 10, round: 0 }), percentLoaded = Math.round(item.percent || 0), isComplete = item.status === "complete", isUploading = item.status === "uploading", isQueued = item.status === "queued";
|
|
@@ -4852,7 +4869,7 @@ const TableRowUpload = (props) => {
|
|
|
4852
4869
|
}
|
|
4853
4870
|
}, [items.length]), null;
|
|
4854
4871
|
}, PickedBar = () => {
|
|
4855
|
-
const
|
|
4872
|
+
const scheme = sanity.useColorSchemeValue(), dispatch = reactRedux.useDispatch(), assetsPicked = useTypedSelector(selectAssetsPicked), handlePickClear = () => {
|
|
4856
4873
|
dispatch(assetsActions.pickClear());
|
|
4857
4874
|
}, handleDeletePicked = () => {
|
|
4858
4875
|
dispatch(dialogActions.showConfirmDeleteAssets({ assets: assetsPicked }));
|
|
@@ -5258,7 +5275,7 @@ const UploadDropzone = (props) => {
|
|
|
5258
5275
|
] }) })
|
|
5259
5276
|
] }) });
|
|
5260
5277
|
}, Browser = (props) => {
|
|
5261
|
-
const client = useVersionedClient(),
|
|
5278
|
+
const client = useVersionedClient(), scheme = sanity.useColorSchemeValue();
|
|
5262
5279
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5263
5280
|
ReduxProvider,
|
|
5264
5281
|
{
|