@rjsf/utils 5.16.1 → 5.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +22 -18
- package/dist/index.js.map +2 -2
- package/dist/utils.esm.js +22 -18
- package/dist/utils.esm.js.map +2 -2
- package/dist/utils.umd.js +22 -18
- package/lib/dataURItoBlob.d.ts +1 -7
- package/lib/dataURItoBlob.js +24 -23
- package/lib/dataURItoBlob.js.map +1 -1
- package/lib/enumOptionsValueForIndex.js +4 -1
- package/lib/enumOptionsValueForIndex.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +2 -0
- package/package.json +6 -6
- package/src/dataURItoBlob.ts +26 -23
- package/src/enumOptionsValueForIndex.ts +6 -1
- package/src/types.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -1853,29 +1853,33 @@ function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateB
|
|
|
1853
1853
|
}
|
|
1854
1854
|
|
|
1855
1855
|
// src/dataURItoBlob.ts
|
|
1856
|
-
function dataURItoBlob(
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
const
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1856
|
+
function dataURItoBlob(dataURILike) {
|
|
1857
|
+
if (dataURILike.indexOf("data:") === -1) {
|
|
1858
|
+
throw new Error("File is invalid: URI must be a dataURI");
|
|
1859
|
+
}
|
|
1860
|
+
const dataURI = dataURILike.slice(5);
|
|
1861
|
+
const splitted = dataURI.split(";base64,");
|
|
1862
|
+
if (splitted.length !== 2) {
|
|
1863
|
+
throw new Error("File is invalid: dataURI must be base64");
|
|
1864
|
+
}
|
|
1865
|
+
const [media, base64] = splitted;
|
|
1866
|
+
const [mime, ...mediaparams] = media.split(";");
|
|
1867
|
+
const type = mime || "";
|
|
1868
|
+
const name = decodeURI(
|
|
1869
|
+
// parse the parameters into key-value pairs, find a key, and extract a value
|
|
1870
|
+
// if no key is found, then the name is unknown
|
|
1871
|
+
mediaparams.map((param) => param.split("=")).find(([key]) => key === "name")?.[1] || "unknown"
|
|
1872
|
+
);
|
|
1869
1873
|
try {
|
|
1870
|
-
const binary = atob(
|
|
1871
|
-
const array =
|
|
1874
|
+
const binary = atob(base64);
|
|
1875
|
+
const array = new Array(binary.length);
|
|
1872
1876
|
for (let i = 0; i < binary.length; i++) {
|
|
1873
|
-
array
|
|
1877
|
+
array[i] = binary.charCodeAt(i);
|
|
1874
1878
|
}
|
|
1875
1879
|
const blob = new window.Blob([new Uint8Array(array)], { type });
|
|
1876
1880
|
return { blob, name };
|
|
1877
1881
|
} catch (error) {
|
|
1878
|
-
|
|
1882
|
+
throw new Error("File is invalid: " + error.message);
|
|
1879
1883
|
}
|
|
1880
1884
|
}
|
|
1881
1885
|
|
|
@@ -1906,7 +1910,7 @@ var import_isEqual4 = __toESM(require("lodash/isEqual"));
|
|
|
1906
1910
|
// src/enumOptionsValueForIndex.ts
|
|
1907
1911
|
function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
|
|
1908
1912
|
if (Array.isArray(valueIndex)) {
|
|
1909
|
-
return valueIndex.map((index2) => enumOptionsValueForIndex(index2, allEnumOptions)).filter((val) => val);
|
|
1913
|
+
return valueIndex.map((index2) => enumOptionsValueForIndex(index2, allEnumOptions)).filter((val) => val !== emptyValue);
|
|
1910
1914
|
}
|
|
1911
1915
|
const index = valueIndex === "" || valueIndex === null ? -1 : Number(valueIndex);
|
|
1912
1916
|
const option = allEnumOptions[index];
|