@rjsf/utils 5.16.0 → 5.17.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 +50 -18
- package/dist/index.js.map +4 -4
- package/dist/utils.esm.js +58 -18
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +58 -18
- package/lib/base64.d.ts +11 -0
- package/lib/base64.js +36 -0
- package/lib/base64.js.map +1 -0
- 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/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/base64.ts +34 -0
- package/src/dataURItoBlob.ts +26 -23
- package/src/enumOptionsValueForIndex.ts +6 -1
- package/src/index.ts +2 -0
package/dist/utils.esm.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
1
9
|
// src/isObject.ts
|
|
2
10
|
function isObject(thing) {
|
|
3
11
|
if (typeof File !== "undefined" && thing instanceof File) {
|
|
@@ -1718,29 +1726,33 @@ function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateB
|
|
|
1718
1726
|
}
|
|
1719
1727
|
|
|
1720
1728
|
// src/dataURItoBlob.ts
|
|
1721
|
-
function dataURItoBlob(
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
const
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1729
|
+
function dataURItoBlob(dataURILike) {
|
|
1730
|
+
if (dataURILike.indexOf("data:") === -1) {
|
|
1731
|
+
throw new Error("File is invalid: URI must be a dataURI");
|
|
1732
|
+
}
|
|
1733
|
+
const dataURI = dataURILike.slice(5);
|
|
1734
|
+
const splitted = dataURI.split(";base64,");
|
|
1735
|
+
if (splitted.length !== 2) {
|
|
1736
|
+
throw new Error("File is invalid: dataURI must be base64");
|
|
1737
|
+
}
|
|
1738
|
+
const [media, base642] = splitted;
|
|
1739
|
+
const [mime, ...mediaparams] = media.split(";");
|
|
1740
|
+
const type = mime || "";
|
|
1741
|
+
const name = decodeURI(
|
|
1742
|
+
// parse the parameters into key-value pairs, find a key, and extract a value
|
|
1743
|
+
// if no key is found, then the name is unknown
|
|
1744
|
+
mediaparams.map((param) => param.split("=")).find(([key]) => key === "name")?.[1] || "unknown"
|
|
1745
|
+
);
|
|
1734
1746
|
try {
|
|
1735
|
-
const binary = atob(
|
|
1736
|
-
const array =
|
|
1747
|
+
const binary = atob(base642);
|
|
1748
|
+
const array = new Array(binary.length);
|
|
1737
1749
|
for (let i = 0; i < binary.length; i++) {
|
|
1738
|
-
array
|
|
1750
|
+
array[i] = binary.charCodeAt(i);
|
|
1739
1751
|
}
|
|
1740
1752
|
const blob = new window.Blob([new Uint8Array(array)], { type });
|
|
1741
1753
|
return { blob, name };
|
|
1742
1754
|
} catch (error) {
|
|
1743
|
-
|
|
1755
|
+
throw new Error("File is invalid: " + error.message);
|
|
1744
1756
|
}
|
|
1745
1757
|
}
|
|
1746
1758
|
|
|
@@ -1771,7 +1783,7 @@ import isEqual4 from "lodash/isEqual";
|
|
|
1771
1783
|
// src/enumOptionsValueForIndex.ts
|
|
1772
1784
|
function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
|
|
1773
1785
|
if (Array.isArray(valueIndex)) {
|
|
1774
|
-
return valueIndex.map((index2) => enumOptionsValueForIndex(index2, allEnumOptions)).filter((val) => val);
|
|
1786
|
+
return valueIndex.map((index2) => enumOptionsValueForIndex(index2, allEnumOptions)).filter((val) => val !== emptyValue);
|
|
1775
1787
|
}
|
|
1776
1788
|
const index = valueIndex === "" || valueIndex === null ? -1 : Number(valueIndex);
|
|
1777
1789
|
const option = allEnumOptions[index];
|
|
@@ -2442,6 +2454,33 @@ function withIdRefPrefix(schemaNode) {
|
|
|
2442
2454
|
return schemaNode;
|
|
2443
2455
|
}
|
|
2444
2456
|
|
|
2457
|
+
// src/base64.ts
|
|
2458
|
+
var base64 = function() {
|
|
2459
|
+
return {
|
|
2460
|
+
encode(text) {
|
|
2461
|
+
let encoder;
|
|
2462
|
+
if (typeof TextEncoder !== "undefined") {
|
|
2463
|
+
encoder = new TextEncoder();
|
|
2464
|
+
} else {
|
|
2465
|
+
const { TextEncoder: TextEncoder2 } = __require("util");
|
|
2466
|
+
encoder = new TextEncoder2();
|
|
2467
|
+
}
|
|
2468
|
+
return btoa(String.fromCharCode(...encoder.encode(text)));
|
|
2469
|
+
},
|
|
2470
|
+
decode(text) {
|
|
2471
|
+
let decoder;
|
|
2472
|
+
if (typeof TextDecoder !== "undefined") {
|
|
2473
|
+
decoder = new TextDecoder();
|
|
2474
|
+
} else {
|
|
2475
|
+
const { TextDecoder: TextDecoder2 } = __require("util");
|
|
2476
|
+
decoder = new TextDecoder2();
|
|
2477
|
+
}
|
|
2478
|
+
return decoder.decode(Uint8Array.from(atob(text), (c) => c.charCodeAt(0)));
|
|
2479
|
+
}
|
|
2480
|
+
};
|
|
2481
|
+
}();
|
|
2482
|
+
var base64_default = base64;
|
|
2483
|
+
|
|
2445
2484
|
// src/enums.ts
|
|
2446
2485
|
var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
|
|
2447
2486
|
TranslatableString2["ArrayItemTitle"] = "Item";
|
|
@@ -2625,6 +2664,7 @@ export {
|
|
|
2625
2664
|
allowAdditionalItems,
|
|
2626
2665
|
ariaDescribedByIds,
|
|
2627
2666
|
asNumber,
|
|
2667
|
+
base64_default as base64,
|
|
2628
2668
|
canExpand,
|
|
2629
2669
|
createErrorHandler,
|
|
2630
2670
|
createSchemaUtils,
|