sanity-plugin-mux-input 3.0.5 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/index.js +20 -92
  2. package/dist/index.js.map +1 -1
  3. package/package.json +5 -15
  4. package/dist/index.cjs +0 -5746
  5. package/dist/index.cjs.map +0 -1
  6. package/dist/index.d.cts +0 -288
  7. package/dist/index.d.cts.map +0 -1
  8. package/sanity.json +0 -8
  9. package/src/_exports/index.ts +0 -73
  10. package/src/actions/assets.ts +0 -152
  11. package/src/actions/secrets.ts +0 -110
  12. package/src/actions/upload.ts +0 -308
  13. package/src/clients/upChunkObservable.ts +0 -54
  14. package/src/components/AddCaptionDialog.tsx +0 -440
  15. package/src/components/CaptionsDialog.tsx +0 -23
  16. package/src/components/ConfigureApi.styled.tsx +0 -19
  17. package/src/components/ConfigureApi.tsx +0 -296
  18. package/src/components/DraggableWatermark.tsx +0 -885
  19. package/src/components/EditCaptionDialog.tsx +0 -511
  20. package/src/components/EditThumbnailDialog.tsx +0 -121
  21. package/src/components/ErrorBoundaryCard.tsx +0 -97
  22. package/src/components/FileInputButton.tsx +0 -54
  23. package/src/components/FileInputMenuItem.styled.tsx +0 -36
  24. package/src/components/FileInputMenuItem.tsx +0 -85
  25. package/src/components/FormField.tsx +0 -38
  26. package/src/components/IconInfo.tsx +0 -22
  27. package/src/components/ImportVideosFromMux.tsx +0 -339
  28. package/src/components/Input.styled.tsx +0 -22
  29. package/src/components/Input.tsx +0 -78
  30. package/src/components/InputBrowser.tsx +0 -41
  31. package/src/components/MuxLogo.tsx +0 -42
  32. package/src/components/Onboard.tsx +0 -65
  33. package/src/components/PageSelector.tsx +0 -54
  34. package/src/components/Player.styled.tsx +0 -11
  35. package/src/components/Player.tsx +0 -117
  36. package/src/components/PlayerActionsMenu.tsx +0 -191
  37. package/src/components/ResyncMetadata.tsx +0 -278
  38. package/src/components/SelectAsset.tsx +0 -39
  39. package/src/components/SelectSortOptions.tsx +0 -45
  40. package/src/components/SpinnerBox.tsx +0 -16
  41. package/src/components/StudioTool.tsx +0 -24
  42. package/src/components/TextTracksEditor.tsx +0 -117
  43. package/src/components/TextTracksManager.tsx +0 -738
  44. package/src/components/UploadConfiguration.tsx +0 -696
  45. package/src/components/UploadPlaceholder.tsx +0 -88
  46. package/src/components/UploadProgress.tsx +0 -80
  47. package/src/components/Uploader.styled.tsx +0 -65
  48. package/src/components/Uploader.tsx +0 -499
  49. package/src/components/VideoDetails/DeleteDialog.tsx +0 -148
  50. package/src/components/VideoDetails/VideoDetails.tsx +0 -358
  51. package/src/components/VideoDetails/VideoReferences.tsx +0 -63
  52. package/src/components/VideoDetails/useVideoDetails.ts +0 -103
  53. package/src/components/VideoInBrowser.tsx +0 -245
  54. package/src/components/VideoMetadata.tsx +0 -45
  55. package/src/components/VideoPlayer.tsx +0 -241
  56. package/src/components/VideoThumbnail.tsx +0 -139
  57. package/src/components/VideosBrowser.tsx +0 -100
  58. package/src/components/documentPreview/DocumentPreview.tsx +0 -84
  59. package/src/components/documentPreview/DraftStatus.tsx +0 -34
  60. package/src/components/documentPreview/MissingSchemaType.tsx +0 -32
  61. package/src/components/documentPreview/PaneItemPreview.tsx +0 -67
  62. package/src/components/documentPreview/PublishedStatus.tsx +0 -35
  63. package/src/components/documentPreview/TimeAgo.tsx +0 -12
  64. package/src/components/icons/Audio.tsx +0 -13
  65. package/src/components/icons/Resolution.tsx +0 -12
  66. package/src/components/icons/StopWatch.tsx +0 -20
  67. package/src/components/icons/ToolIcon.tsx +0 -19
  68. package/src/components/uploadConfiguration/PlaybackPolicy.tsx +0 -133
  69. package/src/components/uploadConfiguration/PlaybackPolicyOption.tsx +0 -76
  70. package/src/components/uploadConfiguration/PlaybackPolicyWarning.tsx +0 -29
  71. package/src/components/uploadConfiguration/ResolutionTierSelector.tsx +0 -72
  72. package/src/components/uploadConfiguration/StaticRenditionSelector.tsx +0 -180
  73. package/src/components/withFocusRing/helpers.ts +0 -24
  74. package/src/components/withFocusRing/index.ts +0 -1
  75. package/src/components/withFocusRing/withFocusRing.ts +0 -30
  76. package/src/context/DialogStateContext.tsx +0 -33
  77. package/src/context/DrmPlaybackWarningContext.tsx +0 -97
  78. package/src/hooks/useAccessControl.ts +0 -13
  79. package/src/hooks/useAssetDocumentValues.ts +0 -11
  80. package/src/hooks/useAssets.ts +0 -73
  81. package/src/hooks/useCancelUpload.ts +0 -22
  82. package/src/hooks/useClient.ts +0 -8
  83. package/src/hooks/useDialogState.ts +0 -11
  84. package/src/hooks/useDocReferences.ts +0 -21
  85. package/src/hooks/useFetchFileSize.ts +0 -55
  86. package/src/hooks/useImportMuxAssets.ts +0 -132
  87. package/src/hooks/useInView.ts +0 -41
  88. package/src/hooks/useMediaMetadata.ts +0 -104
  89. package/src/hooks/useMuxAssets.ts +0 -179
  90. package/src/hooks/useMuxPolling.ts +0 -52
  91. package/src/hooks/useResyncAsset.ts +0 -110
  92. package/src/hooks/useResyncMuxMetadata.ts +0 -169
  93. package/src/hooks/useSaveSecrets.ts +0 -78
  94. package/src/hooks/useSecretsDocumentValues.ts +0 -38
  95. package/src/hooks/useSecretsFormState.ts +0 -47
  96. package/src/plugin.tsx +0 -31
  97. package/src/sanity-ui.d.ts +0 -5
  98. package/src/schema.ts +0 -196
  99. package/src/util/addKeysToMuxData.ts +0 -30
  100. package/src/util/asserters.ts +0 -23
  101. package/src/util/assetTitlePlaceholder.ts +0 -31
  102. package/src/util/constants.ts +0 -15
  103. package/src/util/convertWatermarkToMux.ts +0 -160
  104. package/src/util/createSearchFilter.ts +0 -76
  105. package/src/util/createUrlParamsObject.ts +0 -29
  106. package/src/util/extractFiles.ts +0 -67
  107. package/src/util/formatBytes.ts +0 -31
  108. package/src/util/formatDriveShareLink.ts +0 -64
  109. package/src/util/formatSeconds.ts +0 -48
  110. package/src/util/generateJwt.ts +0 -57
  111. package/src/util/getAnimatedPosterSrc.ts +0 -26
  112. package/src/util/getPlaybackPolicy.ts +0 -69
  113. package/src/util/getPosterSrc.ts +0 -28
  114. package/src/util/getVideoMetadata.ts +0 -23
  115. package/src/util/getVideoSrc.ts +0 -23
  116. package/src/util/parsers.ts +0 -5
  117. package/src/util/pluginVersion.ts +0 -5
  118. package/src/util/readSecrets.ts +0 -38
  119. package/src/util/roundPxString.ts +0 -16
  120. package/src/util/textTracks.ts +0 -222
  121. package/src/util/tryWithSuspend.ts +0 -22
  122. package/src/util/types.ts +0 -566
  123. package/v2-incompatible.js +0 -11
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { useClient as useClient$1, createHookFromObservableFactory, useDocumentS
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
3
  import { ErrorOutlineIcon, InfoOutlineIcon, RetryIcon, CheckmarkCircleIcon, RetrieveIcon, ChevronLeftIcon, ChevronRightIcon, SyncIcon, SortIcon, UploadIcon, TranslateIcon, DownloadIcon, AddIcon, ChevronUpIcon, ChevronDownIcon, TrashIcon, EditIcon, WarningOutlineIcon, PublishIcon, DocumentIcon, RevertIcon, SearchIcon, ClockIcon, CropIcon, CalendarIcon, TagIcon, CheckmarkIcon, LockIcon, PlayIcon, PlugIcon, EllipsisHorizontalIcon, ImageIcon, ResetIcon, WarningFilledIcon, DocumentVideoIcon } from "@sanity/icons";
4
4
  import { Dialog, Stack, Card, Text, Button, useTheme_v2, Flex, Box, TextInput, Checkbox, Code, Inline, Spinner, Heading, Label as Label$1, Radio, MenuButton, Menu, MenuItem, useToast, Autocomplete, Tooltip, TabList, Tab, TabPanel, Grid, useClickOutsideEvent, Popover, MenuDivider, rem } from "@sanity/ui";
5
- import React, { createContext, useState, useCallback, useMemo, useContext, useReducer, useId, memo, useRef, useEffect, Suspense, isValidElement, PureComponent, forwardRef } from "react";
5
+ import { createContext, useState, useCallback, useMemo, useContext, useReducer, useId, memo, useRef, useEffect, Suspense, isValidElement, forwardRef } from "react";
6
6
  import compact from "lodash/compact.js";
7
7
  import toLower from "lodash/toLower.js";
8
8
  import trim from "lodash/trim.js";
@@ -22,6 +22,7 @@ import isString from "lodash/isString.js";
22
22
  import { useObservable } from "react-rx";
23
23
  import useSWR from "swr";
24
24
  import scrollIntoView from "scroll-into-view-if-needed";
25
+ import { useErrorBoundary } from "use-error-boundary";
25
26
  import { UpChunk } from "@mux/upchunk";
26
27
  import { isValidElementType } from "react-is";
27
28
  const ToolIcon = () => /* @__PURE__ */ jsx("svg", { stroke: "currentColor", fill: "currentColor", strokeWidth: "0", viewBox: "0 0 24 24", height: "1em", width: "1em", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M21 3H3c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.11-.9-2-2-2zm0 14H3V5h18v12zm-5-6l-7 4V7z" }) }), LOCAL_STORAGE_HAS_SHOWN_WARNING_KEY = "mux-plugin-has-shown-drm-playback-warning", DrmPlaybackWarningContext = createContext({
@@ -141,7 +142,7 @@ function useDialogState() {
141
142
  const PLUGIN_VERSION_QUERY = {
142
143
  sanityVersion: (
143
144
  // @ts-expect-error - this constant is search/replaced so must be exact, not accessed with an index signature
144
- "3.0.5"
145
+ "4.0.1"
145
146
  )
146
147
  };
147
148
  function saveSecrets(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate, drmConfigId) {
@@ -663,7 +664,7 @@ function accumulateIntermediateState(currentState, pageResult) {
663
664
  validAssets,
664
665
  skippedInThisPage
665
666
  } = newAssets.reduce((acc, asset) => {
666
- const hasPlaybackIds = asset.playback_ids && asset.playback_ids.length > 0, isDuplicate = currentData.some((a2) => a2.id === asset.id);
667
+ const hasPlaybackIds = asset.playback_ids && asset.playback_ids.length > 0, isDuplicate = currentData.some((a) => a.id === asset.id);
667
668
  return hasPlaybackIds || (acc.skippedInThisPage = !0), hasPlaybackIds && !isDuplicate && acc.validAssets.push(asset), acc;
668
669
  }, {
669
670
  validAssets: [],
@@ -721,7 +722,7 @@ function useImportMuxAssets() {
721
722
  }), [assetsInSanity, assetsInSanityLoading] = useAssetsInSanity(documentStore), hasSecrets = !!useSecretsDocumentValues().value.secrets?.secretKey, [importError, setImportError] = useState(), [importState, setImportState] = useState("closed"), dialogOpen = importState !== "closed", muxAssets = useMuxAssets({
722
723
  client,
723
724
  enabled: hasSecrets && dialogOpen
724
- }), missingAssets = useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((a2) => !assetExistsInSanity(a2, assetsInSanity)) : void 0, [assetsInSanity, muxAssets.data]), [selectedAssets, setSelectedAssets] = useState([]), closeDialog = () => {
725
+ }), missingAssets = useMemo(() => assetsInSanity && muxAssets.data ? muxAssets.data.filter((a) => !assetExistsInSanity(a, assetsInSanity)) : void 0, [assetsInSanity, muxAssets.data]), [selectedAssets, setSelectedAssets] = useState([]), closeDialog = () => {
725
726
  importState !== "importing" && setImportState("closed");
726
727
  }, openDialog = () => {
727
728
  importState === "closed" && setImportState("idle");
@@ -1097,8 +1098,8 @@ function ImportVideosDialog(props) {
1097
1098
  /* @__PURE__ */ jsx(Box, { flex: 1, paddingLeft: 3, as: "label", htmlFor: "import-all", children: /* @__PURE__ */ jsx(Text, { children: "Import all" }) })
1098
1099
  ] }),
1099
1100
  props.missingAssets.map((asset) => /* @__PURE__ */ jsx(MissingAsset, { asset, selectAsset: (selected) => {
1100
- selected ? props.setSelectedAssets([...props.selectedAssets, asset]) : props.setSelectedAssets(props.selectedAssets.filter((a2) => a2.id !== asset.id));
1101
- }, selected: props.selectedAssets.some((a2) => a2.id === asset.id) }, asset.id))
1101
+ selected ? props.setSelectedAssets([...props.selectedAssets, asset]) : props.setSelectedAssets(props.selectedAssets.filter((a) => a.id !== asset.id));
1102
+ }, selected: props.selectedAssets.some((a) => a.id === asset.id) }, asset.id))
1102
1103
  ] })
1103
1104
  ] }) });
1104
1105
  }
@@ -2258,16 +2259,16 @@ function TextTracksManager({
2258
2259
  }, 3e3);
2259
2260
  return () => clearInterval(interval);
2260
2261
  }, [allTracks, asset, resyncAsset]);
2261
- const visibleTracks = allTracks.filter((track) => track.status === "ready" || track.status === "preparing" || track.status === "errored").sort((a2, b) => {
2262
- const orderA = trackActivityOrder.get(a2.id) || 0, orderB = trackActivityOrder.get(b.id) || 0;
2262
+ const visibleTracks = allTracks.filter((track) => track.status === "ready" || track.status === "preparing" || track.status === "errored").sort((a, b) => {
2263
+ const orderA = trackActivityOrder.get(a.id) || 0, orderB = trackActivityOrder.get(b.id) || 0;
2263
2264
  if (orderA > 0 && orderB > 0)
2264
2265
  return orderB - orderA;
2265
2266
  if (orderA > 0) return -1;
2266
2267
  if (orderB > 0) return 1;
2267
- const aIsPreparing = a2.status === "preparing", bIsPreparing = b.status === "preparing";
2268
+ const aIsPreparing = a.status === "preparing", bIsPreparing = b.status === "preparing";
2268
2269
  if (aIsPreparing && !bIsPreparing) return -1;
2269
2270
  if (!aIsPreparing && bIsPreparing) return 1;
2270
- const aIsAutogenerated = a2.id && a2.id.startsWith("generating-") || a2.id && autogeneratedTrackIds.has(a2.id), bIsAutogenerated = b.id && b.id.startsWith("generating-") || b.id && autogeneratedTrackIds.has(b.id);
2271
+ const aIsAutogenerated = a.id && a.id.startsWith("generating-") || a.id && autogeneratedTrackIds.has(a.id), bIsAutogenerated = b.id && b.id.startsWith("generating-") || b.id && autogeneratedTrackIds.has(b.id);
2271
2272
  return aIsAutogenerated && !bIsAutogenerated ? -1 : !aIsAutogenerated && bIsAutogenerated ? 1 : 0;
2272
2273
  }), handleDownload = async (track) => {
2273
2274
  if (track.id) {
@@ -2559,7 +2560,7 @@ function VideoPlayer({
2559
2560
  /* @__PURE__ */ jsx(MuxPlayer, { poster: isAudio ? void 0 : poster, ref: muxPlayer, ...props, playsInline: !0, playbackId, tokens, preload: "metadata", crossOrigin: "anonymous", metadata: {
2560
2561
  player_name: "Sanity Admin Dashboard",
2561
2562
  // @ts-expect-error - this constant is search/replaced so must be exact, not accessed with an index signature
2562
- player_version: "3.0.5",
2563
+ player_version: "4.0.1",
2563
2564
  page_type: "Preview Player"
2564
2565
  }, audio: isAudio, _hlsConfig: hlsConfig, style: {
2565
2566
  ...!isAudio && {
@@ -2913,7 +2914,7 @@ const AssetInput = (props) => /* @__PURE__ */ jsx(FormField, { title: props.labe
2913
2914
  saveChanges,
2914
2915
  handleResync,
2915
2916
  isResyncing
2916
- } = useVideoDetails(props), isSaving = state === "saving", [containerHeight, setContainerHeight] = useState(null), contentsRef = React.useRef(null);
2917
+ } = useVideoDetails(props), isSaving = state === "saving", [containerHeight, setContainerHeight] = useState(null), contentsRef = useRef(null);
2917
2918
  return useEffect(() => {
2918
2919
  !contentsRef.current || !("getBoundingClientRect" in contentsRef.current) || setContainerHeight(contentsRef.current.getBoundingClientRect().height);
2919
2920
  }, []), /* @__PURE__ */ jsxs(Dialog, { animate: !0, header: displayInfo.title, zOffset: DIALOGS_Z_INDEX, id: "video-details-dialog", onClose: handleClose, onClickOutside: handleClose, width: 2, position: "fixed", footer: /* @__PURE__ */ jsx(Card, { padding: 3, children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", children: [
@@ -3011,7 +3012,7 @@ function VideoInBrowser({
3011
3012
  onEdit,
3012
3013
  asset
3013
3014
  }) {
3014
- const [renderVideo, setRenderVideo] = useState(!1), select = React.useCallback(() => onSelect?.(asset), [onSelect, asset]), edit = React.useCallback(() => onEdit?.(asset), [onEdit, asset]), {
3015
+ const [renderVideo, setRenderVideo] = useState(!1), select = useCallback(() => onSelect?.(asset), [onSelect, asset]), edit = useCallback(() => onEdit?.(asset), [onEdit, asset]), {
3015
3016
  hasShownWarning
3016
3017
  } = useDrmPlaybackWarningContext();
3017
3018
  if (!asset)
@@ -3082,7 +3083,7 @@ function VideosBrowser({
3082
3083
  setSearchQuery,
3083
3084
  setSort,
3084
3085
  sort
3085
- } = useAssets(), [page, setPage] = useState(0), pageLimit = 20, pageTotal = Math.floor(assets.length / pageLimit) + 1, [editedAsset, setEditedAsset] = useState(null), freshEditedAsset = useMemo(() => assets.find((a2) => a2._id === editedAsset?._id) || editedAsset, [editedAsset, assets]), pageStart = page * pageLimit, pageEnd = pageStart + pageLimit;
3086
+ } = useAssets(), [page, setPage] = useState(0), pageLimit = 20, pageTotal = Math.floor(assets.length / pageLimit) + 1, [editedAsset, setEditedAsset] = useState(null), freshEditedAsset = useMemo(() => assets.find((a) => a._id === editedAsset?._id) || editedAsset, [editedAsset, assets]), pageStart = page * pageLimit, pageEnd = pageStart + pageLimit;
3086
3087
  return /* @__PURE__ */ jsxs(DrmPlaybackWarningContextProvider, { config, children: [
3087
3088
  /* @__PURE__ */ jsxs(Stack, { padding: 4, space: 4, style: {
3088
3089
  minHeight: "50vh"
@@ -3163,79 +3164,6 @@ const useAccessControl = (config) => {
3163
3164
  dedupingInterval: 1e3
3164
3165
  });
3165
3166
  };
3166
- var c = (function(r) {
3167
- var t, e;
3168
- function n(t2) {
3169
- var e2;
3170
- return (e2 = r.call(this, t2) || this).state = {
3171
- hasError: !1,
3172
- error: null
3173
- }, e2;
3174
- }
3175
- e = r, (t = n).prototype = Object.create(e.prototype), t.prototype.constructor = t, t.__proto__ = e, n.getDerivedStateFromError = function(r2) {
3176
- return {
3177
- hasError: !0,
3178
- error: r2
3179
- };
3180
- };
3181
- var o = n.prototype;
3182
- return o.componentDidCatch = function(r2, t2) {
3183
- return this.props.onDidCatch(r2, t2);
3184
- }, o.render = function() {
3185
- var r2 = this.state, t2 = this.props, e2 = t2.render, n2 = t2.children, o2 = t2.renderError;
3186
- return r2.hasError ? o2 ? o2({
3187
- error: r2.error
3188
- }) : null : e2 ? e2() : n2 || null;
3189
- }, n;
3190
- })(PureComponent), u = function(r, t) {
3191
- switch (t.type) {
3192
- case "catch":
3193
- return {
3194
- didCatch: !0,
3195
- error: t.error
3196
- };
3197
- case "reset":
3198
- return {
3199
- didCatch: !1,
3200
- error: null
3201
- };
3202
- default:
3203
- return r;
3204
- }
3205
- };
3206
- function a(t) {
3207
- var a2 = useReducer(u, {
3208
- didCatch: !1,
3209
- error: null
3210
- }), i = a2[0], d = a2[1], h = useRef(null);
3211
- function l() {
3212
- return e = function(r, e2) {
3213
- d({
3214
- type: "catch",
3215
- error: r
3216
- }), t && t.onDidCatch && t.onDidCatch(r, e2);
3217
- }, function(t2) {
3218
- return React.createElement(c, {
3219
- onDidCatch: e,
3220
- children: t2.children,
3221
- render: t2.render,
3222
- renderError: t2.renderError
3223
- });
3224
- };
3225
- var e;
3226
- }
3227
- var p, s = useCallback(function() {
3228
- h.current = l(), d({
3229
- type: "reset"
3230
- });
3231
- }, []);
3232
- return {
3233
- ErrorBoundary: (p = h.current, p !== null ? p : (h.current = l(), h.current)),
3234
- didCatch: i.didCatch,
3235
- error: i.error,
3236
- reset: s
3237
- };
3238
- }
3239
3167
  function ErrorBoundaryCard$1(props) {
3240
3168
  const {
3241
3169
  children,
@@ -3247,7 +3175,7 @@ function ErrorBoundaryCard$1(props) {
3247
3175
  didCatch,
3248
3176
  error,
3249
3177
  reset
3250
- } = a({
3178
+ } = useErrorBoundary({
3251
3179
  // oxlint-disable-next-line no-unstable-nested-components
3252
3180
  onDidCatch: (err, errorInfo) => {
3253
3181
  console.group(err.toString()), console.groupCollapsed("console.error"), console.error(err), console.groupEnd(), err.stack && (console.groupCollapsed("error.stack"), console.log(err.stack), console.groupEnd()), errorInfo?.componentStack && (console.groupCollapsed("errorInfo.componentStack"), console.log(errorInfo.componentStack), console.groupEnd()), console.groupEnd(), pushToast({
@@ -3946,12 +3874,12 @@ function formatBytes(bytes, si = !1, dp = 1) {
3946
3874
  if (Math.abs(bytes) < thresh)
3947
3875
  return bytes + " B";
3948
3876
  const units = si ? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] : ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
3949
- let u2 = -1;
3877
+ let u = -1;
3950
3878
  const r = 10 ** dp;
3951
3879
  do
3952
- bytes /= thresh, ++u2;
3953
- while (Math.round(Math.abs(bytes) * r) / r >= thresh && u2 < units.length - 1);
3954
- return bytes.toFixed(dp) + " " + units[u2];
3880
+ bytes /= thresh, ++u;
3881
+ while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
3882
+ return bytes.toFixed(dp) + " " + units[u];
3955
3883
  }
3956
3884
  const RangeInput = styled.input.withConfig({
3957
3885
  displayName: "RangeInput",