@ea-lab/reactive-json
Version:
A REACT-based lib that transforms JSON (or YAML) into interactive HTML markup.
61 lines (60 loc) • 1.88 kB
JavaScript
import "react/jsx-runtime";
import "../../jsonpath-B9kE9k9e.js";
import "../../lodash-CYNxjS-I.js";
import "react";
import "../../engine/GlobalDataContext.js";
import "../../engine/TemplateContext.js";
import { evaluateTemplateValue as V } from "../../engine/TemplateSystem.js";
import "../../engine/EventDispatcherContext.js";
import "../../engine/EventDispatcherProvider.js";
import "../../engine/PaginationContext.js";
import "../../dnd-kit-sortable-tree.esm-Cz1RJyIg.js";
import { normalizeAttributeNameForReactJsx as w } from "../../engine/utility/reactJsxHelpers.js";
import "../../index-NNBvIV0S.js";
import "../../js-yaml-CFDLc3Ha.js";
import "../../engine/ParsingDebugDisplay/ParsingDebugDisplay.js";
const y = ({ attributes: t, globalDataContext: l, singleTransformProps: A, templateContext: a }) => {
const { name: s, value: m, separator: c = " ", unsetAllOccurrences: C, unsetCount: p } = A || {};
if (!s || m === void 0)
return t;
const n = String(
V({
valueToEvaluate: m,
globalDataContext: l,
templateContext: a
})
), u = p !== void 0 ? V({
valueToEvaluate: p,
globalDataContext: l,
templateContext: a
}) : void 0, i = w(s), f = t[i] || "";
if (!f)
return t;
let e = [...f.split(c)];
(() => {
if (C === !0) {
e = e.filter((r) => r !== n);
return;
}
const o = parseInt(u, 10);
if (!(!isNaN(o) && u !== void 0 && u !== null)) {
e = e.filter((r) => r !== n);
return;
}
if (o === 0)
return;
if (o > 0) {
let r = 0;
e = e.filter((T) => T === n && r < o ? (r++, !1) : !0);
return;
}
const N = Math.abs(o);
let d = 0;
e = e.reverse().filter((r) => r === n && d < N ? (d++, !1) : !0).reverse();
})();
const v = e.join(c);
return v.trim() === "" ? delete t[i] : t[i] = v, t;
};
export {
y as unsetAttributeValue
};