@paraboly/pwc-multi-filter
Version:
A wrapper over pwc-tabview and pwc-filter. Provides means of dynamically managing multiple filters via a single component.
31 lines (28 loc) • 1.21 kB
JavaScript
import { E as Enumerable } from './linq-c2ddb1d7.js';
function resolveJson(input) {
// TODO: returning [] when no input only works because of our limited usage in this component.
// We should return an instance of TReturnType instead.
return input ? (typeof input === "string" ? JSON.parse(input) : input) : [];
}
function getVanillaHtmlInputs(rootElement, skipButtonElements) {
return Enumerable.from(rootElement.querySelectorAll("input"))
.where(inputElement => {
const inputElementParents = getAllParentElements(inputElement);
const isChoices = Enumerable.from(inputElementParents).any(p => p.tagName.includes("PWC-CHOICES"));
const isButton = inputElement.type === "button";
const isPwcColorPicker = Enumerable.from(inputElementParents).any(p => p.tagName.includes("PWC-COLOR-PICKER"));
return (false ===
(isChoices || (skipButtonElements && isButton) || isPwcColorPicker));
})
.toArray();
}
function getAllParentElements(node) {
let a = node;
const els = [];
while (a) {
els.unshift(a);
a = a.parentElement;
}
return els;
}
export { resolveJson as r };