filepond
Version:
FilePond, where files go to stretch their bits.
115 lines (114 loc) • 2.81 kB
JavaScript
/*!
* FilePond v5.0.2
* Copyright (c) 2017-2026 Pqina B.V.
* Released under the MIT License
* https://filepond.com
*/
import { lowerCaseFirstLetter as V, upperCaseFirstLetter as d } from "../../utils/string.js";
import { arrayRemoveFalsy as j } from "../../utils/array.js";
import { isString as m, isLocaleUnitKey as x, isObject as v, isLocaleTemplate as h, isNullOrUndefined as a } from "../../utils/test.js";
import { createDefaultIcon as K } from "./html.js";
import { hasOwnProp as S } from "../../utils/object.js";
import { cache as T } from "../../utils/cache.js";
function C(...t) {
return j(t).join(" ") || void 0;
}
function w(t) {
return V(
`${t.split("_").map((e) => d(e.toLowerCase())).join("")}`
);
}
function F(t, e) {
return g(t.substring(2, t.length - 2), e);
}
function g(t, e) {
const r = t.split(".");
for (const n of r)
if (e = e[n], a(e))
return "";
return e;
}
function l(t, e, r = {}) {
if (m(t)) {
if (!e)
return t;
const n = Array.from(t.matchAll(/\{{[\.a-z]+\}}/gi));
if (!n.length)
return t;
for (const { 0: c } of n) {
const o = F(c, e);
let s = r[o] ?? o;
if (x(o) && v(s)) {
const i = c.substring(2, c.length - 6);
s = l(
{
template: "{{v}}",
variables: {
v: {
context: i,
// @ts-ignore
map: s
}
}
},
e,
r
);
}
t = t.replace(c, s);
}
return l(t, e, r);
}
if (h(t)) {
const { variables: n, template: c } = t, o = Object.entries(n).reduce(
(s, [i, u]) => {
let y, f;
"context" in u && m(u.context) ? (y = u.context, f = u.map) : (y = i, f = u);
const p = g(y, e), L = a(f[p]) ? f.else : f[p];
return s.replace(`{{${i}}}`, `${L}`);
},
c
);
return l(o, e, r);
}
}
function D(t, e, r = "") {
return m(t) ? e[t] ?? t : r;
}
function O({ code: t, subcode: e, values: r }, n) {
const o = T(w, [e ?? t]), s = n[o], i = !a(s) && (m(s) || h(s));
if (i)
return i ? l(s, r, n) : void 0;
}
function U({ type: t }, e, r) {
const n = t, c = !a(r[n]), o = !a(e[n]);
if (!(!c || !o))
return K(r[n], {
// Should also have title
title: e[n]
});
}
function k(t, e, r) {
const n = Object.keys(e);
if (!n.some((o) => S(t, o)))
return t;
const c = {
...t
};
for (const o of n) {
if (t[o] === void 0) continue;
const s = e[o], i = t[o];
c[o] = r[s][i] ?? i;
}
return c;
}
export {
g as getObjectValueByString,
D as getValueByKeyFromData,
w as statusCodeToLocaleKey,
U as statusToIcon,
O as statusToLabel,
l as stringReplaceVariables,
C as toSpaceSeparatedString,
k as withResources
};